package cn.getech.data.development.model.vo;

import cn.getech.data.development.entity.BdpServiceAlarm;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 服务告警
 * @author chenshiyang
 * @since 2021-05-17
 */
@Data
public class ServiceAlarmVO extends BdpServiceAlarm {

    //免打扰时间，开始
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8")
    private Date noDisturbingStartTime;
    //免打扰时间，结束
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8")
    private Date noDisturbingEntTime;
    //最后发送时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date lastSendTime;
    //创建时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    //创建人
    private Integer createPer;
    //创建人
    private String createName;
    //更新时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;
    //更新人
    private Integer updatePer;
    //服务集合
    private List<Map<String,Object>> serviceList;
    //接收人集合
    private List<Map<String,Object>> receiverList;

    public String getTriggerConditionTitle(){
        if(this.getTriggerCondition()==null){
            return "";
        }
        switch (this.getTriggerCondition()){
            case 0:return "失败";
            case 1:return "成功";
        }
        return "";
    }

    public String getAlarmModeTitle(){
        if(this.alarmMode==null){
            return "";
        }
        switch (this.alarmMode){
            case "1":return "邮件";
            case "2":return "T信";
            case "3":return "电话";
            case "4":return "短信";
        }
        return "";
    }

    public String getReceivedTypeTitle(){
        if(this.receivedType==null){
            return "";
        }
        switch (this.receivedType){
            case 1:return "部门";
            case 2:return "项目";
            case 3:return "个人";
            case 4:return "本人";
        }
        return "";
    }

    public String getStateTitle(){
        if(this.state==null){
            return "";
        }
        switch (this.state){
            case 0:return "禁用";
            case 1:return "启用";
        }
        return "";
    }

    public String getTaskTypeTitle(){
        return "数据服务";
    }

    //告警方式，1：邮件，2：T信，3：电话，4：短信
    private String alarmMode;
    //接收人类型，1：部门，2：项目，3：个人，4：本人
    private Integer receivedType;
    //告警状态，1：启用，0：禁用
    private Integer state;

}
